#ifndef ANIMATIONCONTROLWIDGET_H
#define ANIMATIONCONTROLWIDGET_H

#include <QWidget>
#include <QTimer>

class AnimationControlWidget : public QWidget
{
    Q_OBJECT

    struct Frame
    {
        QRectF rect;
        int frameIndex;
    };

public:
    explicit AnimationControlWidget(QWidget *parent = 0);

    bool isPlaying() const;
private:
    void resizeEvent(QResizeEvent *);
    void paintEvent(QPaintEvent *);
    void mousePressEvent(QMouseEvent *pEvent);
    void mouseMoveEvent(QMouseEvent *pEvent);
    void mouseReleaseEvent(QMouseEvent *pEvent);
    void updateFrameRects();
    int m_nNumFrames;
    int m_nCurrFrame;
    bool m_bGrabbed;
    QList<Frame> m_frames;

    QTimer m_timer;
signals:
    void currentFrameChanged(int cf);
public slots:
    void setNumFrames(int numFrames);
    void setCurrentFrame(int cf);
    void onTimer();

    void play();
    void stop();
    void rewind();
    void goToEnd();
    void stepBackward();
    void stepForward();
    void togglePlayback();
};

#endif // ANIMATIONCONTROLWIDGET_H
